<template>
<learn-communal action-key="communal">
  <n-flex vertical>
    <n-space justify="space-between">
      <n-button type="primary" @click="back">返回</n-button>
    </n-space>
    <n-grid cols="1 s:2 m:3 l:4 xl:6 2xl:8" responsive="screen" x-gap="12" y-gap="12" item-responsive>
      <n-gi v-for="(item, index) in getClass" :key="index">
        <n-card hoverable @click="toPage('std/curriculum/show', {classId:item.id,node:item.classNode,type:'class'},false)">
          <template #cover>
            <n-image preview-disabled src='/src/assets/picture/loginBg.png' />
          </template>
          <n-tag type="info" size="small">{{ item.classTitle }}-{{index+1}}</n-tag>
          <span> | </span>
          <n-tag type="info" size="small">课程节点：{{ item.classNode }}</n-tag>
        </n-card>
      </n-gi>
    </n-grid>
  </n-flex>
</learn-communal>
</template>

<script setup>
import learnCommunal from "@/components/communal/learn-communal.vue";
import {ref, toRefs} from "vue";
import {useRoute} from "vue-router";
import {getClassByClassId, getClassByClassType} from "@/res/api/class_api.js";
import {inject} from "vue";
const {toPage} = inject('toPage')
// 接收路由传参
let route = useRoute()
let {query} = toRefs(route)
// 点击课程封面进入课程
let  getClass = ref([])
getClassByClassType({classType: query.value.classType})
    .then((res) => {
      console.log(res.data.list)
      getClass.value = res.data.list
    })
// 返回上一级
function back(){
  history.go(-1)
}
const emit = defineEmits({

})



</script>

<style lang="scss" scoped>

</style>
